package com.hccl.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.*;
import java.util.Properties;

/**
 * Created by sunjia on 2018/4/10.
 * 常量类：管理路径和配置文件
 */
@Component
public class Constants {

    public static String corpusPath="lib/corpus/";
    public static String jsonPath="lib/nodeInfo/nodeInfo.json";
    public static String nodeInfoPath="lib/nodeInfo/";
    public static String classifierModelPath="lib/classifier_lib/model.bin";
    public static String classifierPropPath="lib/classifier_lib/classifier.prop";
    public static String classifierTraindataPath="lib/classifier_lib/traindata";
    public static String homonymPath="lib/preprocess_lib/homonym.dic";
    public static String gateJapePath="lib/gate_lib/plugins/jape/";
    public static String gateGazetteerPath="lib/gate_lib/plugins/gazetteer/";
    public static String gappUrl="lib/gate_lib/plugins/anguang.gapp";
    public static String gateHome = "lib/gate_lib/gate.xml";
    public static String gateANNIEPath = "lib/gate_lib/plugins/ANNIE/";
    public static String segDicPath = "lib/segment_lib/default.dic";

    @Value("${dialogManager.useContext}")
    private String useContext;
    @Value("${dialogManager.url}")
    private String url;
    @Value("${slu.poolSize}")
    private int poolSize;
    @Value("${dialogManager.timeout}")
    private int timeOut;

    public String getUseContext() {
        return useContext;
    }

    public String getUrl() {
        return url;
    }

    public int getPoolSize() {
        return poolSize;
    }

    public int getTimeOut() {
        return timeOut;
    }

//    public static String inputEncoding;
//    public static String outputEncoding;
//    public static String useContext;
//    public static String url;
//    public static int poolSize;
//    public static int timeOut;
//
//    static{
//        try {
//            Properties property = new Properties();
//            InputStream in = new BufferedInputStream(new FileInputStream("lib/config.inf"));
//            property.load(new InputStreamReader(in, "utf-8"));
//            inputEncoding = property.getProperty("InputEncoding");
//            outputEncoding = property.getProperty("OutputEncoding");
//            poolSize = Integer.valueOf(property.getProperty("Nthread"));
//            useContext = property.getProperty("isUseContext","false");
//            url =  property.getProperty("DialogManagerURL","http://192.168.2.222:8080/tbi/csf_");
//            timeOut =  Integer.valueOf(property.getProperty("Timeout", "5000"));
//        } catch (Exception e) {
//            System.err.println("配置文件config.inf读取失败，使用默认配置。");
//            System.exit(-1);
//        }
//    }
}
